package com.aaron.type.time;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author liurong
 * @date 2021/8/13 10:34
 * @version:
 */
public class DateTimeFormatterTest {

    public static void main(String[] args) {
        ExecutorService executorService = Executors.newFixedThreadPool(100);

        for (int i = 0; i < 20; i++) {
            executorService.execute(()->{
                for (int j = 0; j < 10; j++) {
                    DateTimeFormatterUtil.parse("2021-08-13 00:33:22");
                }
            });
        }
    }

}

class DateTimeFormatterUtil {

    private static final DateTimeFormatter fomatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    public static String format(LocalDateTime dateTime) {
        return fomatter.format(dateTime);
    }

    public static LocalDateTime parse(String dateTimeStr) {
        return LocalDateTime.parse(dateTimeStr, fomatter);
    }
}

